package stream;
/*
获取Stream获取流对象（将数据放在流水线的传送带上）
1.单列集合获取流对象
    XXX.stream.
2.双列集合获取流对象
    Map.entrySet.
3.数组获取流对象
    Arrays.stream.
4.零散的数据获取流对象
    Stream.of.

 */
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class StreamDemo1 {
    public static void main(String[] args) {
        method1();
        method2();
        method3();
    }

    private static void method3() {
        //零散的数据获取流对象
        Stream.of(1, 2, 6, 7).forEach(s-> System.out.println(s));
        Stream.of("啊啊啊","wefdw","呃呃呃").forEach(s-> System.out.println(s));
    }

    //数组获取流对象
    private static void method2() {
        int[] arr1 = {11,2,66};
        double[] arr2 = {1.1,88.2,84.9};
        Arrays.stream(arr1).forEach(s-> System.out.println(s));
        Arrays.stream(arr2).forEach(s-> System.out.println(s));
    }

    //单双列集合获取流对象
    private static void method1() {
        //单列集合如何获取stream流对象
        List<String> list = new ArrayList<String>();
        list.add("张一我");
        list.add("王国");
        list.add("张二的");
        list.add("增强");
        list.stream().forEach(s-> System.out.println(s));
        Set<String> set = new HashSet<String>();
        set.addAll(list);
        set.stream().forEach(s-> System.out.println(s));
        System.out.println("------------------------------");
        Map<String,Integer> map = new HashMap<>();
        map.put("A",23);
        map.put("B",48);
        map.put("Cddd",65);
        map.put("Dee",58);
        //拿到所有的键
        map.keySet().stream().forEach(System.out::println);
        //拿到所有的值
        map.values().stream().forEach(System.out::println);
        //拿到键值对
        map.entrySet().stream().forEach(System.out::println);
    }
}
